<template>
  <div style='width: 100%'>
    <!-- <div class='block' style='margin-bottom: 20px'>
      <span
        class='demonstration'
        style='display: block; float: left; margin-right: 20px'
        ><h2>选择年份：</h2></span
      >
      <el-date-picker
        v-model='value4'
        type='month'
        placeholder='选择月'
        style='margin-top: 20px; margin-right: 20px'
      >
      </el-date-picker>
      <el-button type='primary' v-on:click='applyDownload'>数据导出</el-button>
    </div> -->

    <el-form :inline='true'>
      <el-form-item label='年份选择'>
        <el-date-picker
          v-model='year'
          type='month'
          placeholder='选择月'
          style='margin-top: 10px; margin-right: 20px'
          @change='yearSelect'
          format='yyyy-MM '
          value-format='yyyy-MM'
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label=''>
        <el-button type='primary' v-on:click='applyDownload' style='margin-top: 10px'
          >数据导出</el-button
        >
      </el-form-item>
    </el-form>
    <!-- 对应弹框InvestmentProjectsTbActivityWindow -->
    <div>
      <el-dialog :visible.sync='windowVisible' append-to-body>
        <InvestmentProjectsTbActivityWindow
          v-if='windowVisible'
          ref='popWindow'
        ></InvestmentProjectsTbActivityWindow>
        <span slot='footer' class='dialog-footer'>
          <el-button @click='windowVisible = false'>取消</el-button>
          <el-button type='primary' @click='windowVisible = false'
            >确定</el-button
          >
        </span>
      </el-dialog>
    </div>
    <el-row style='height: 450px; width: 1300px'>
      <el-col :span='24'>
        <el-table
          :data='tableData.slice((pageNo - 1) * page_size, pageNo * page_size)'
          size='mini'
          style='width: 100%'
          header-cell-class-name='table-header-gray'
          v-loading='isShowloading'
          border='1px solid gray'
        >
          <el-table-column
            type='index'
            align='center'
            label='序号'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='clueSource'
            align='center'
            label='信息提供人'
            width='120'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='projectTrack'
            align='center'
            label='项目前期跟踪'
            width='120'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='keyName'
            align='center'
            label='关键因素项目成功推动'
            width='150'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='contracts'
            align='center'
            label='成功落地签订合同'
            width='150'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strProCodeGetDate'
            align='center'
            label='领取编号日期'
            width='150'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='projectCode'
            align='center'
            label='项目编号'
            width='120'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='projectName'
            align='center'
            label='项目名称'
            width='150'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='customerName'
            align='center'
            label='业主名称'
            width='150'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strContractCreateTime'
            align='center'
            label='领取合同日期'
            width='180'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strContractGetState'
            align='center'
            label='合同收回情况'
            width='180'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strContractAmount'
            align='center'
            label='合同金额（元）'
            width='120'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='tenderType'
            align='center'
            label='招标类型'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='projectManager'
            align='center'
            label='项目经理'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='areaName'
            align='center'
            label='项目区域'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='regulatory'
            align='center'
            label='监管部门'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strProjectInvestment'
            align='center'
            label='工程投资（元）'
            width='120'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strTenderPrice'
            align='center'
            label='中标价（元）'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strTenderTime'
            align='center'
            label='开标时间'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='tenderAmount'
            align='center'
            label='投标家数'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strTenderFee'
            align='center'
            label='标书费（元）'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strAgencyFee'
            align='center'
            label='代理费（元）'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strIncome'
            align='center'
            label='收入-评标费（元）'
            width='130'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strPay'
            align='center'
            label='支出-评标费（元）'
            width='130'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strSettlementTime'
            align='center'
            label='结算时间'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strBackAmount'
            align='center'
            label='应收款（元）'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strReceivedAmount'
            align='center'
            label='已回款（元）'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strRecordTime'
            align='center'
            label='备案时间'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='strProjectStatus'
            align='center'
            label='项目进展'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop='remark'
            align='center'
            label='备注'
            width='100'
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            label='操作'
            align='center'
            fixed='right'
            width='100'
          >
            <template slot-scope='scope'>
              <el-button
                type='text'
                @click='handleInfo(scope.$index, scope.row)'
                icon='el-icon-view'
                size='mini'
                >查看</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <el-row type='flex' justify='end' style='margin-top: 10px'>
          <el-pagination
            background
            @size-change='handleSizeChange'
            @current-change='handleCurrentChange'
            :current-page='pageNo'
            :page-size='page_size'
            :page-sizes='[10, 20, 30]'
            layout='total, prev, pager, next, sizes'
            :total='total'
          ></el-pagination>
        </el-row>
      </el-col>
    </el-row>
    <!--
<el-dropdown>
  <span class='el-dropdown-link'>
    2022<i class='el-icon-arrow-down el-icon--right'></i>
  </span>
  <el-dropdown-menu slot='dropdown'>
    <el-dropdown-item>全部</el-dropdown-item>
    <el-dropdown-item>2021</el-dropdown-item>
    <el-dropdown-item>2020</el-dropdown-item>
    <el-dropdown-item>2019</el-dropdown-item>
  </el-dropdown-menu>
</el-dropdown> -->
  </div>
</template>

<script>
import InvestmentProjectsTbActivityWindow from '@/components/views/InvestmentProjectsTbActivityWindow';
import InvitationStatisticsTable from '@/api/BigDataAnalysis/InvitationStatisticsTable';
import { baseUrl } from '../../core/config/development';
export default {
  components: {
    InvestmentProjectsTbActivityWindow
  },
  data () {
    return {
      windowVisible: false,
      addOperate: undefined,
      tableData: [],
      states: [
        {
          value: '全部',
          lable: '全部'
        },
        {
          value: '进行中',
          lable: '进行中'
        },
        {
          value: '已完成',
          lable: '已完成'
        }
      ],
      value: '',
      value1: '全部',
      total: 0,
      page_size: 10,
      pageNo: 1,
      isShowloading: false,
      year: '',
      state: ''
    };
  },
  directives: {
    focus: {
      // 指令的定义
      inserted: function (el) {
        el.focus();
      }
    }
  },
  mounted: function () {
    this.loadTableData();
    // this.loadYears();
  },
  methods: {
    yearSelect () {
      this.loadTableData();
    },
    //     loadYears() {
    //   let currentYear = new Date().getFullYear();
    //   this.value = currentYear;
    //   this.year = currentYear;
    //   this.years = [];
    //   this.years.push({ value: '全部', lable: '全部' });
    //   for (let i = 0; i < 11; i++) {
    //     this.years.push({
    //       value: currentYear - i,
    //       label: currentYear - i + '年',
    //     });
    //   }
    // },

    handleInfo (index, row) {
      this.windowVisible = true;
      this.addOperate = false;
      this.$nextTick(() => {
        this.$refs.popWindow.dataInit(row);
      });
    },
    /**
     * 获取表格数据
     */
    loadTableData () {
      let params = {
        size: this.page_size,
        current: this.pageNo,
        yearall: this.year,
        state: this.state
      };
      return new Promise((resolve, reject) => {
        InvitationStatisticsTable.bidList(this, params)
          .then((res) => {
            this.tableData = res.data.records;
            this.total = res.data.total;
          })
          .catch((e) => {
            reject(e);
          });
      });
    },
    // 年份选择
    selectTime (data) {
      this.year = data;
      this.loadTableData();
    },
    // 分页导航
    handleCurrentChange (val) {
      this.pageNo = val;
      this.loadTableData();
    },
    handleSizeChange (val) {
      this.page_size = val;
      this.loadTableData();
    },
    currentChange (val) {
      this.pageNo = val;
      this.loadTableData();
    },
    applyDownload () {
      // window.location.href = 'http://localhost:6666/api/excel'

      // this.batchId = '20191128093017';

      //   this.$ajax
      //     .get('/plat/checkBatchId', {
      //       params: {
      //         batchId: this.batchId
      //       }
      //     })
      //     .then(res => {
      //       console.log(res);
      //       if(res.data.code=='200'){
      // location.href = 'http://192.168.1.60:8081/plat/outExcel'
      var year = this.year;
      // window.alert(year);
      var url = baseUrl + 'apiExcel/investmentTbExcel?yearall=' + year;
      // var url ='http://'+document.location.host+'/api/excel'
      window.location.href = url;
      //   }else{

      //     alert('偶哦~出错了！')
      //   }
      // });
    }
  }
};
</script>
